Skip to content

[bigint] Optimize parsing of numeric strings#50

Merged
forfudan merged 2 commits intomainfrom
work
Mar 23, 2025
Merged

[bigint] Optimize parsing of numeric strings#50
forfudan merged 2 commits intomainfrom
work

Conversation

@forfudan
Copy link
Copy Markdown
Owner

This pull request includes several changes to the decimojo package, specifically focusing on improving the BigInt arithmetic operations and parsing of numeric strings. The most important changes include the introduction of a new method to check if a BigInt is zero, replacing string-based coefficients with list-based coefficients, and adding new augmented arithmetic assignment methods.

Improvements to BigInt arithmetic operations:

  • src/decimojo/bigint/arithmetics.mojo: Introduced the is_zero method to simplify zero-checks in the add function.
  • src/decimojo/bigint/arithmetics.mojo: Corrected the return statements in the add, subtract, and negative functions to properly return the result.
  • src/decimojo/bigint/arithmetics.mojo: Simplified the absolute function by directly returning the negated value if the sign is set.

Parsing and coefficient handling:

  • src/decimojo/str.mojo: Changed the parse_string_of_number function to return a list of UInt8 coefficients instead of a string, improving efficiency and clarity.
  • src/decimojo/bigint/bigint.mojo: Updated the from_string method to use the new list-based coefficients and adjusted the logic to handle these coefficients.

New augmented arithmetic assignment methods:

  • src/decimojo/bigint/bigint.mojo: Added __iadd__ and __isub__ methods for in-place addition and subtraction, respectively.

@forfudan forfudan merged commit 67d6b24 into main Mar 23, 2025
1 check passed
@forfudan forfudan deleted the work branch March 23, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant